public class test {
    //使用for循环来求1-1/2+1/3....-1/100的和
    public static void main(String[] args) {
        double sum =0.0;
        double sign =1.0;
        for (double i=1.0;i<=100;i++){
            sum=sum+sign/i;
            sign=-sign;
        }
        System.out.println(sum);
    }
}
